package com.xgjweb.fsi.service;

import java.util.List;

import com.xgjweb.common.dao.ICommonDao;
import com.xgjweb.common.service.CommonServiceImpl;
import com.xgjweb.common.utils.XgjWebLogger;
import com.xgjweb.common.utils.XgjWebUtils;
import com.xgjweb.fsi.domain.Journal;
import com.xgjweb.fsi.domain.Message;
import com.xgjweb.fsi.dto.InitalDto;
import com.xgjweb.fsi.dto.MessageDto;

/**
 * 
 * @author xgj
 * 
 */
public class InitializeServiceImpl extends CommonServiceImpl implements
		IInitializeService {
	private ICommonDao messageDao;
	private ICommonDao journalDao;

	public void setMessageDao(ICommonDao messageDao) {
		this.messageDao = messageDao;
	}

	public void setJournalDao(ICommonDao journalDao) {
		this.journalDao = journalDao;
	}

	@SuppressWarnings("unchecked")
	public InitalDto indexInit() throws Exception {
		try {
			Journal journal = new Journal();
			journal.setStatementName("selectTop4Journal");
			List<Journal> journalList = journalDao.selectByList(journal);
			MessageDto messageDto = new MessageDto();
			messageDto.setStatementName("findMessageForIndex");
			messageDto = (MessageDto) messageDao.selectByObject(messageDto);
			InitalDto initalDto=new InitalDto();
			initalDto.setJournals(journalList);
			initalDto.setMessageDto(messageDto);
			return initalDto;
		} catch (Exception e) {
			XgjWebLogger.getInstance().error(e.getMessage(), e);
			throw e;
		}
	}

}
